package com.woniu.controller.homepage;

import com.woniu.entity.Address;
import com.woniu.service.homePage.IAddressService;
import com.woniu.util.ResData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 凌雨
 * @data 2023/3/9 10:38
 */
@RestController
@RequestMapping("/app/address")
public class AddressController {

    @Autowired
    private IAddressService addressService;

    /**
     * 查询用户收货地址
     * @param phone 用户的手机号
     * @return
     */
    @RequestMapping("/queryAddressByPhone")
    public ResData<?> queryAddressByPhone(String phone) {
        return addressService.queryAddressByPhone(phone);
    }

    /**
     * 修改用户地址
     * @param address 用户的收货地址
     */
    @RequestMapping("/updateAddress")
    public ResData<?> updateAddress(@RequestBody Address address) {
        return addressService.updateAddress(address);
    }

    /**
     * 删除用户收货地址
     * @param id  收货地址编号
     * @return
     */
    @RequestMapping("/removeAddress")
    public ResData<?> removeAddress(Integer id,String phone) {
        return addressService.removeAddress(id,phone);
    }


    /**
     * 增加用户收货地址
     * @param address 用户的收货地址
     */
    @RequestMapping("/saveAddress")
    public ResData<?> saveAddress(@RequestBody Address address) {
        return addressService.saveAddress(address);
    }



}
